<template>
  <a-card :bordered="false">
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-card title="组织架构">
            <a-card-grid style="width:50%;text-align:center">
              <input type="checkbox" v-model="queryParam.org1" v-bind:true-value="1000015019" v-bind::false-value="1"/>
              平高电器
            </a-card-grid>
            <a-card-grid style="width:50%;text-align:center" :hoverable="false">
              <input type="checkbox" v-model="queryParam.org2" v-bind:true-value="1000014563" v-bind::false-value="1"/>平芝
            </a-card-grid>
            <a-card-grid style="width:25%;text-align:center">
              <input type="checkbox" v-model="queryParam.orgName1" v-bind:true-value="40001" v-bind::false-value="1"/>组合电器
            </a-card-grid>
            <a-card-grid style="width:25%;text-align:center">
              <input type="checkbox" v-model="queryParam.orgName2" v-bind:true-value="40002" v-bind::false-value="1"/>断路器
              {{queryParam.orgName}}
            </a-card-grid>
          </a-card>
        </a-row>
        <a-row v-if="show" style="padding-top: 30px">
          <a-col :md="6" :sm="8">
            <a-form-item label="合同名称">
              <a-input placeholder="合同名称" v-model="queryParam.conName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8" style="padding-left: 10px">
            <a-form-item label="合同编号">
              <a-input placeholder="合同编号" v-model="queryParam.conCode"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8" style="padding-left: 10px">
            <a-form-item label="采购订单编码">
              <a-input placeholder="采购订单编码" v-model="queryParam.poNo"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8" style="padding-left: 10px">
            <a-form-item label="合同签订日期">
              <a-input placeholder="合同签订日期" v-model="queryParam.sellerSignTime"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8" style="padding-left: 10px">
            <a-form-item label="工程项目名称">
              <a-input placeholder="工程项目名称" v-model="queryParam.prjName"></a-input>
            </a-form-item>
          </a-col>
        </a-row>
        <!--<a-row :gutter="24">-->
        <!--<a-card>-->
        <!--<a-card title="平高" :bordered="false">-->
        <!--<a-col :span="12">-->
        <!--<a-card title="组合电器">-->
        <!--</a-card>-->
        <!--</a-col>-->
        <!--<a-col :span="12">-->
        <!--<a-card title="断路器">-->
        <!--</a-card>-->
        <!--</a-col>-->
        <!--</a-card>-->
        <!--</a-card>-->
        <!--<a-card>-->
        <!--<a-card title="平芝" :bordered="false" >-->
        <!--</a-card>-->
        <!--</a-card>-->
        <!--</a-row>-->
        <!--<a-row>-->
        <!--<a-col >-->
        <!--<a-form-item label="销售订单号">-->
        <!--<a-input placeholder="销售订单号" v-model="queryParam.soNo"></a-input>-->
        <!--</a-form-item>-->
        <!--</a-col>-->
        <!--</a-row>-->
        <a-row :gutter="24" style="padding-top: 30px">
          <a-col :md="5" :sm="5">
            <!-- 操作按钮区域 -->
            <span class="table-operator">
              <!--<a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>-->
              <a-button type="primary" icon="download" @click="handleExportXls('eip_purchase_order')">导出</a-button>
              <!--<a-button  type="primary" icon="plus">校验</a-button>-->
              <!--<a-button  type="primary" icon="plus">审核</a-button>-->
              <!--<a-dropdown v-if="selectedRowKeys.length > 0">-->
              <!--<a-menu slot="overlay">-->
              <!--<a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>-->
              <!--</a-menu>-->
              <!--<a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>-->
              <!--</a-dropdown>-->
            </span>
          </a-col>
          <a-col :md="5" :sm="5">
            <a-form-item label="采购订单号">
              <a-input placeholder="采购订单号" v-model="queryParam.poNo"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="5" :sm="5">
            <j-date v-model="queryParam.dataSourceCreateTime" :showTime="true" date-format="YYYY-MM-DD"
                    style="width:45%" placeholder="请选择日期"></j-date>
          </a-col>
          <a-col :md="5" :sm="5">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
            </span>
          </a-col>
          <a-col :md="4" :sm="4">
            <a-button type="primary" @click="showOrClose" icon="search">高级查询</a-button>
          </a-col>
        </a-row>
      </a-form>

    </div>
    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{
        selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="puid"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">

        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无此图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="图片不存在"
               style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无此文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="uploadFile(text)">
            下载
          </a-button>
        </template>

        <!--<span slot="action" slot-scope="text, record">-->
        <!--<a @click="handleEdit(record)">编辑</a>-->

        <!--<a-divider type="vertical" />-->
        <!--<a-dropdown>-->
        <!--<a class="ant-dropdown-link">更多 <a-icon type="down" /></a>-->
        <!--<a-menu slot="overlay">-->
        <!--<a-menu-item>-->
        <!--<a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">-->
        <!--<a>删除</a>-->
        <!--</a-popconfirm>-->
        <!--</a-menu-item>-->
        <!--</a-menu>-->
        <!--</a-dropdown>-->
        <!--</span>-->

      </a-table>
    </div>

    <eipPurchaseOrder-modal ref="modalForm" @ok="modalFormOk"></eipPurchaseOrder-modal>
  </a-card>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import EipPurchaseOrderModal from './modules/EipPurchaseOrderModal'

  export default {
    name: 'EipPurchaseOrderList',
    mixins: [JeecgListMixin],
    components: {
      EipPurchaseOrderModal
    },
    data() {
      return {
        description: 'eip_purchase_order管理页面',
        show: false,
        orgName1: '',
        orgName2: '',
        org1: '',
        org2: '',
        // 表头
        columns: [
          {
            title: '采购方编码',
            align: 'center',
            dataIndex: 'purchaserCode'
          },
          {
            title: '供应商编码',
            align: 'center',
            dataIndex: 'supplierCode'
          },
          {
            title: '供应商名称',
            align: 'center',
            dataIndex: 'supplierName'
          },
          {
            title: '采购订单编号',
            align: 'center',
            dataIndex: 'poNo'
          },
          {
            title: '采购订单行项目号',
            align: 'center',
            dataIndex: 'poItemNo'
          },
          {
            title: '采购订单行项目id',
            align: 'center',
            dataIndex: 'poItemId'
          },
          {
            title: '合同编号',
            align: 'center',
            dataIndex: 'conCode'
          },
          {
            title: '合同名称',
            align: 'center',
            dataIndex: 'conName'
          },
          {
            title: '采购方公司名称',
            align: 'center',
            dataIndex: 'buyerName'
          },
          {
            title: '采购方物料编码',
            align: 'center',
            dataIndex: 'materialCode'
          },
          {
            title: '采购方物料描述',
            align: 'center',
            dataIndex: 'materialDesc'
          },
          {
            title: '采购数量',
            align: 'center',
            dataIndex: 'amount'
          },
          {
            title: '合同编号（国网经法）',
            align: 'center',
            dataIndex: 'sellerConCode'
          },
          {
            title: '技术规范流水号',
            align: 'center',
            dataIndex: 'serialNumber'
          },
          {
            title: '合同签订日期',
            align: 'center',
            dataIndex: 'sellerSignTime',
            customRender: function(text) {
              return !text ? '' : (text.length > 10 ? text.substr(0, 10) : text)
            }
          },
          {
            title: '合同类型',
            align: 'center',
            dataIndex: 'conType'
          },
          {
            title: '项目编号',
            align: 'center',
            dataIndex: 'prjCode'
          },
          {
            title: '工程项目名称',
            align: 'center',
            dataIndex: 'prjName'
          },
          {
            title: '物资编码',
            align: 'center',
            dataIndex: 'matCode'
          }


          // {
          //   title: '操作',
          //   dataIndex: 'action',
          //   align:"center",
          //   scopedSlots: { customRender: 'action' },
          // }
        ],
        url: {
          list: '/eipPurchaseOrder/selectForList',
          // delete: "/pg/eipPurchaseOrder/delete",
          // deleteBatch: "/pg/eipPurchaseOrder/deleteBatch",
          // exportXlsUrl: "/pg/eipPurchaseOrder/exportXls",
          importExcelUrl: '/eipPurchaseOrder/importExcel'
        },
        dictOptions: {}
      }
    },
    computed: {
      importExcelUrl: function() {
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
      }
    },
    methods: {
      initDictConfig() {
      },
      showOrClose() {
        this.show = !this.show
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>